<template>
  <view class="role-selection-container">
    <view class="header-text">请选择您的身份</view>
    
    <view class="role-options">
      <view class="role-card" @click="selectRole('lender')">
        <view class="role-icon lender-icon">
          <text>出</text>
        </view>
        <view class="role-title">我是出借方</view>
        <view class="role-desc">我借钱给别人钱</view>
      </view>
      
      <view class="role-card" @click="selectRole('borrower')">
        <view class="role-icon borrower-icon">
          <text>借</text>
        </view>
        <view class="role-title">我是借款方</view>
        <view class="role-desc">我向别人借钱</view>
      </view>
    </view>
    
    <view class="back-btn" @click="goBack">返回首页</view>
  </view>
</template>

<script>
export default {
  data() {
    return {}
  },
  methods: {
    selectRole(role) {
      // 保存角色信息到本地存储
      uni.setStorageSync('userRole', role);
      
      // 跳转到借条表单页面
      uni.navigateTo({
        url: `/pages/loan/${role}`
      });
    },
    
    goBack() {
      uni.switchTab({
        url: '/pages/home/index'
      });
    }
  }
}
</script>

<style lang="scss">
.role-selection-container {
  min-height: 100vh;
  background-color: #f5f7fa;
  padding: 0 30rpx;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.header-text {
  font-size: 34rpx;
  font-weight: 500;
  color: #333;
  text-align: center;
  margin-top: 40rpx;
  margin-bottom: 30rpx;
}

.role-options {
  display: flex;
  flex-direction: column;
  gap: 20rpx;
  margin-bottom: auto;
}

.role-card {
  background-color: #fff;
  border-radius: 12rpx;
  padding: 30rpx;
}

.role-icon {
  width: 46rpx;
  height: 46rpx;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24rpx;
  font-weight: bold;
  margin-bottom: 15rpx;
}

.lender-icon {
  background-color: #1989fa;
  color: #fff;
}

.borrower-icon {
  background-color: #ff5252;
  color: #fff;
}

.role-title {
  font-size: 32rpx;
  font-weight: 500;
  color: #333;
  margin-bottom: 8rpx;
}

.role-desc {
  font-size: 26rpx;
  color: #999;
}

.back-btn {
  width: 100%;
  height: 90rpx;
  background-color: #fff;
  color: #1989fa;
  font-size: 30rpx;
  border-radius: 45rpx;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 40rpx;
  margin-bottom: 40rpx;
  border: 1px solid #1989fa;
}
</style> 